<template>
  <div>
    <h1>Demo View</h1>
    <button @click="checkConnection">Check Servlet Connection</button>
    <p>{{ message }}</p>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  data() {
    return {
      message: ''
    }
  },
  methods: {
    async checkConnection() {
      try {
        const response = await axios.get('http://localhost:8080/LibraryBack_war_exploded/demoServlet');
        this.message = response.data.message;
      } catch (error) {
        console.error(error);
        this.message = 'Failed to connect to Servlet';
      }
    }
  }
}
</script>
